home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / applications / wp / mced-1.0.lha / CEDScripts / Paginate.ced < prev    next >
Encoding:
Text File  |  1992-09-02  |  2.4 KB  |  75 lines

  1. /*
  2. **    Paginate.ced
  3. **    
  4. **    $VER: Paginate.ced 1.0 (3.1.95)
  5. **    
  6. **    This scripts insert page numbers at the bottom of each page in current
  7. **    file. Number of lines per page must be given explictly as there is no
  8. **    way to get it from CED.
  9. **    See docs for more details.
  10. **    
  11. **    This script requires CygnusEd Professional v3.5 (or later) to run.
  12. **    
  13. **    Copyright © 1995 Michael Letowski
  14. */
  15.  
  16. /* Get host */
  17. PARSE SOURCE com res called resolved ext host .
  18. IF host="REXX" THEN                                                /* From command line */
  19.     ADDRESS "rexx_ced"                                            /* Talk to default ced */
  20.  
  21. OPTIONS RESULTS                                                        /* Enable results from commands */
  22. ARG lpp opt .                                                            /* Check for 'FF' option */
  23.  
  24. /* Set up global variables */
  25. G.LF="0A"X
  26. IF DataType(lpp,"N") THEN                                    /* This is number */
  27.     G.LinesPerPage=lpp                                            /* Set to user value */
  28. ELSE                                                                            /* Not given or not number */
  29.     G.LinesPerPage=66                                                /* Set to default value */
  30. G.Ops=0                                                                        /* Number of operations for undo */
  31. IF opt="FF" THEN G.FF="0C"X                                /* Option given */
  32. ELSE G.FF="0A"X                                                        /* Option not given */
  33.  
  34. 'Status CURSORCOLUMN'                                            /* Get current cursor column */
  35. Column=RESULT+1
  36. 'Status CURSORLINE'                                                /* Get current cursor line */
  37. Line=RESULT+1
  38.  
  39. 'Status RIGHTBORDER'                                            /* Get number of line chars */
  40. G.CharsPerLine=RESULT
  41.  
  42. 'Status NUMLINES'                                                    /* Get number of lines in file */
  43. NumLines=RESULT
  44.  
  45. NumPages=NumLines%(G.LinesPerPage-2)        /* Compute number of pages */
  46. LastLines=G.LinesPerPage-NumLines//(G.LinesPerPage-2)-2
  47.  
  48. 'DM "Paginating..."'                                            /* Let the user know what's going on */
  49. DO I=1 TO NumPages                                                /* For each page... */
  50.     CALL InsPageNum(I)                                            /* Insert pagination */
  51. END
  52.  
  53. 'End of file'                                                            /* Go to end */
  54. 'Text' Copies(G.LF,LastLines)                            /* Insert blank lines */
  55. G.Ops=G.Ops+RESULT
  56. CALL InsPageNum(NumPages+1)                                /* Insert last pagination */
  57.  
  58. CALL SetClip(UndoClipName(),G.Ops)                /* Set data for Undo.ced */
  59.  
  60. 'DM'                                                                            /* Restore status line */
  61. 'LL' Line Column                                                    /* Restore cursor position */
  62.  
  63. EXIT
  64.  
  65. InsPageNum:    PROCEDURE EXPOSE G.                        /* Procedure to insert page number */
  66.     ARG pageNum
  67.     'LL' pageNum*G.LinesPerPage-1 1
  68.     'Text' G.LF||Strip(Center("-" pageNum "-",G.CharsPerLine),"T")||G.FF
  69.     G.Ops=G.Ops+RESULT
  70. RETURN
  71.  
  72. UndoClipName:
  73.     'Status FILEMEM'                                                /* Get address of current file */
  74. RETURN "CEDUndo."Right(D2X(RESULT),8,"0")    /* Prepare unique name */
  75.